<%@ page isELIgnored="false" contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="com.isaac.edu.pojo.Resume" %>
<%@ page import="java.util.List" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Resume List</title>
    <link rel="stylesheet" href="${contextPath}/resources/css/bootstrap.css">
    <link rel="stylesheet" href="${contextPath}/resources/layui/css/layui.css">

    <script src="${contextPath}/resources/js/jquery.min.js"></script>
    <script src="${contextPath}/resources/js/bootstrap.min.js"></script>
    <script src="${contextPath}/resources/layui/layui.js"></script>
    <script src="${contextPath}/resources/layui/layui.all.js"></script>

    <script type="text/javascript">
        $(function () {
            $(document).on('click', ".updateBtn", function () {
                var edit = $(this).parent().parent();
                $("#updateForm .id").val(edit.children().eq(0).text());
                $("#updateForm .name").val(edit.children().eq(1).text());
                $("#updateForm .address").val(edit.children().eq(2).text());
                $("#updateForm .phone").val(edit.children().eq(3).text());

                layer.open({
                    type: 1,
                    title: '修改Resume',
                    content: $('#updateForm')
                });

            }).on('click', "#addResume", function () {
                layer.open({
                    type: 1,
                    title: '新增Resume',
                    content: $('#addForm')
                });
            }).on('click', ".deleteBtn", function () {
                var edit = $(this).parent().parent();
                var id = edit.children().eq(0).text();
                $.ajax({
                    url:'delete',
                    type:'POST',
                    data: {
                        "id" : id
                    },
                    dataType: 'json',
                    success: function(result){
                        if(result){
                            location.href="indexPage";
                        }else{
                            layer.open({
                                type:1,
                                area:['400px','300px'],
                                shadeClose:true,
                                content:'删除失败'
                            });
                        }
                    },
                    error:function () {
                        alert("异常！");
                    }
                })
            })
         });


    </script>
</head>
<body>
<div class="container-fluid">
    <form action="showPlan.htm" role="form" method="POST" id="planForm">
        <div class="row" style="float:right;margin:10px;">
            <a class="btn btn-info" id="addResume" style="margin:10px">新增</a>
        </div>
        <div class="row" style=" padding-right: 10px;   background-color: #f7f7f7;">
            <div class="col-sm-12">
                <div class="panel-body">
                    <table class="table table-hover table-bordered table-background-gray table-striped">
                        <colgroup>
                            <col style="width:20%;">
                            <col style="width:20%;">
                            <col style="width:30%;">
                            <col style="width:30%;">
                        </colgroup>
                        <thead>
                        <tr style="background: #CCCCCC">
                            <th class="text-center">Id</th>
                            <th class="text-center">地址</th>
                            <th class="text-center">姓名</th>
                            <th class="text-center">手机</th>
                            <th class="text-center">操作</th>
                        </tr>
                        </thead>
                        <tbody id="content">
                        <%
                            List<String> resumeList = (java.util.List<String>) request.getAttribute("resumeList");
                        %>
                        <c:forEach items="${resumeList}" var="Resume" varStatus="vs">
                            <tr>
                                <td class="text-center" style=" vertical-align: middle;" id="id">${Resume.id}</td>
                                <td class="text-center" style=" vertical-align: middle;" id="address">${Resume.address}</td>
                                <td class="text-center" style=" vertical-align: middle;" id="name">${Resume.name}</td>
                                <td class="text-center" style=" vertical-align: middle;" id="phone">${Resume.phone}</td>
                                <td class="text-center">
                                    <a class="btn btn-sm btn-success updateBtn">修改</a>
                                    <a class="btn btn-sm btn-warning deleteBtn">删除</a>
                                </td>
                            </tr>
                        </c:forEach>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </form>
</div>

<form action="/Resume/insert" role="form" method="post" id="addForm" style="display: none">
        <div class="form-horizontal">
            <div class="form-group">
                <label class="col-sm-4 control-label">
                    姓名：
                </label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="name" placeholder="请输入姓名"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">
                    地址：
                </label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="address" placeholder="请输入地址"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">
                    电话：
                </label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="phone" placeholder="请输入电话"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-6">
                    <input type="submit" value="提交">
                </div>
                <div class="col-sm-6">
                    <input type="button" id="cancel" value="取消">
                </div>
            </div>
        </div>
    </form>

<form action="/Resume/update" role="form" method="post" id="updateForm" style="display: none">
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-sm-4 control-label">
                ID：
            </label>
            <div class="col-sm-8">
                <input type="text" class="form-control id"  name="id" readonly/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">
                姓名：
            </label>
            <div class="col-sm-8">
                <input type="text" class="form-control name" name="name" placeholder="请输入姓名"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">
                地址：
            </label>
            <div class="col-sm-8">
                <input type="text" class="form-control address" name="address" placeholder="请输入地址"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">
                电话：
            </label>
            <div class="col-sm-8">
                <input type="text" class="form-control phone" name="phone" placeholder="请输入电话"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-6">
                <input type="submit" value="提交">
            </div>
        </div>
    </div>
</form>



</body>

</html>